# -*- coding: UTF-8 -*-
# from django.test import TestCase

# Create your tests here.
import requests
import pdb, json

# pdb.set_trace()
baseUrl = u"http://127.0.0.1:8000/api/user/"
testUrl = u"https://epioneer.info/api/user/"


# def test1():
#     data = {

#     }
#     res = requests.get(baseUrl + 'test/', data=data)
#     pdb.set_trace()
#     print(res.content)
#     # res = client.post(baseUrl + 'test/', request, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
#     # print(res.content)
# pdb.set_trace()
def test1():
    data = {

    }
    res = requests.get(testUrl + 'test1/', data=data)
    # pdb.set_trace()
    print(res.content)

def generateInviteCode():
    data = {

    }
    res = requests.get(baseUrl + 'generate/', data=data)
    print(res.content.decode('utf-8'))

# 注册
def signup():
    data = {
        'inviteCode': '852F04',
        'phone':'18610478915',
        'password':'123456'
    }
    res = requests.post(baseUrl + 'signup/', data=data)
    print(res.content.decode('utf-8'))

def loginnowx():
    data = {
        'username': '13810450499',
        'userpwd': '123456'
    }
    res = requests.post(testUrl + 'loginnowx/', data=data)
    print(res.content.decode('utf-8'))

def changePassword():
    data = {
        'token': '74ebcae426411dedfb8e',
        'oldPassword': '123456789',
        'newPassword': '123456',
    }
    res = requests.post(baseUrl + 'changePassword/', data=data)
    print(res.content.decode('utf-8'))

# 登录
def login():
    data = {
        'code': '021CcIkl2nHW794lQvml2SrrC11CcIkT',
    }
    res = requests.post(baseUrl + 'login/', data=data)
    print(res.content.decode('utf-8'))


# 登出
def logout():
    data = {
        'token': 'e30bc7c35334df914961',
    }
    res = requests.post(baseUrl + 'logout/', data=data)
    print(res.content.decode('utf-8'))


def updatezsdy():
    data = {
        'token': '5583ac8ab273dc27ffba',
        'branch': "通三党支部",
        'classNum': "通信1801",
        'name': "曾有成",
        'phone': "13810450499",
        'stuNum': "2018010905",
        'userType': "正式党员",
    }
    res = requests.post(baseUrl + 'updatezsdy/', data=data)
    print(res.content.decode('utf-8'))

# 更新其他人员信息
def updateOther():
    data = {
        'token': '3380694168363b69f215',
        'branch': "通三党支部",
        'classNum': "通信2001",
        'name': "通三积极分子",
        'phone': "13812341234",
        'stuNum': "2020010000",
        'userType': "积极分子",
        'devPeo1': "曾有成-2018010905",
        'devPeo2': "白钦-2018010999",
    }
    res = requests.post(baseUrl + 'updateother/', data=data)
    print(res.content.decode('utf-8'))

# 获得阿里云token
def getAliToken():
    data = {
        'token': '95b93fad71feca830133',
    }
    # pdb.set_trace()
    response = requests.post(baseUrl + 'practice/osstoken', data=data)
    print(response.content)

def getDY():
    data = {
        'token': '895717ed3336665e48cd',
        'branch':'通三党支部',
    }
    # pdb.set_trace()
    response = requests.post(baseUrl + 'getdy/', data=data)
    print(response.content.decode('utf-8'))



if __name__ == '__main__':
    test1()
    # generateInviteCode()
    # getDY()
    # signup()
    # loginnowx()
    # changePassword()
    # login()
    # logout()
    # updatezsdy()
    # updateOther()

